Skip to content

Conversation

@staskus
Copy link
Contributor

@staskus staskus commented Jul 31, 2025

WOOMOB-953

Description

As @jaclync has noticed when doing PR Review for #15956 the card payments would succeed, but POS was left stuck in "Processing..." screen.

Investigation

I tested TestFlight versions and confirmed that the issue wasn't reproducible on 22.8 but was reproducible on the current beta, 22.9.

I couldn't pinpoint an issue by looking at the changes so I did a git bisect that pointed to this commit.

What this small change did was expose a slight timing issue when onPaymentCompletion() was called. onPaymentCompletion() was relying on isEligibleForBackendReceipts check being synchronous, so alert presentation would be called before payment completion. However, after this commit, isEligibleForBackendReceipts became asynchronous, and alert presentation was called after onPaymentCompletion().

It didn't cause issues for IPP because of the different ways CollectOrderPaymentUseCase was used. For POS, CardPresentPaymentCollectOrderPaymentUseCaseAdaptor would deinitialize CollectOrderPaymentUseCase after a successful payment. Therefore, alert presenters were never called to notify about successful payment

Solution

The solution is straightforward. Move onPaymentCompletion() into isEligibleForBackendReceipts to ensure alert presenters are called before completing the payment.

I also added a test to ensure the expected event order.

Steps to reproduce

  • Verify card payments work on the POS and result in a "success" view

Testing information

  • iPad Air 18.5 simulator and iPad 26 device + M2 reader
  • Failed and successful payments
  • IPP and POS

  • I have considered if this change warrants user-facing release notes and have added them to RELEASE-NOTES.txt if necessary.

isEligibleForBackendReceipts is async resulting in onPaymentCompletion called before alert presentation is done.

This causes CardPresentPaymentCollectOrderPaymentUseCaseAdaptor to deinitialize CollectOrderPaymentUseCase before payment success is shown resulting in card payment stuck at processing step.
@dangermattic
Copy link
Collaborator

1 Warning
⚠️ This PR is assigned to the milestone 22.9 ❄️. The due date for this milestone has already passed.
Please assign it to a milestone with a later deadline or check whether the release for this milestone has already been finished.

Generated by 🚫 Danger

@wpmobilebot
Copy link
Collaborator

App Icon📲 You can test the changes from this Pull Request in WooCommerce iOS Prototype by scanning the QR code below to install the corresponding build.

App NameWooCommerce iOS Prototype
Build Numberpr15967-a3e400c
Version22.9
Bundle IDcom.automattic.alpha.woocommerce
Commita3e400c
Installation URL0q78tmlh4bji8
Automatticians: You can use our internal self-serve MC tool to give yourself access to those builds if needed.

Copy link
Contributor

@jaclync jaclync left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM! :shipit: Thanks a lot for looking into the root cause and fixing it properly. I tested in a simulator with simulated card reader enabled, and a physical device with a card reader, for successful payments in both POS and IPP without getting stuck.

}

// Then ensure payment completion happens after alert presentation to avoid CollectOrderPaymentUseCase deinit before alert presentation
XCTAssertEqual(eventOrder, [.receiptEligibilityCheck, .alertPresented, .paymentCompletion])
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice way of testing this 👍

@jaclync
Copy link
Contributor

jaclync commented Jul 31, 2025

Merging this now to post about releasing a new beta, cc @RafaelKayumov.

@jaclync jaclync merged commit abfca0a into release/22.9 Jul 31, 2025
20 of 22 checks passed
@jaclync jaclync deleted the woomob-953-woo-pos-card-payments-are-not-succeeding-on-229-beta branch July 31, 2025 22:39
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants